<template>
  <div class="container">
    <div class="basicinfo-container">
      <div class="box basic-info">
        <span>我的地址</span>
        <div class="info-input">
          <input type="text" ref="nameInput" :value="Address" />
        </div>
      </div>
      <div class="sumbit-button">
        <button class="hover:bg-blue-600" @click="sumbit">保存</button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      Address: "",
    };
  },
  methods: {
    getUserInfo() {
      this.$taxios
        .postInfo("/getUserInfo", { token: sessionStorage.getItem("token") })
        .then((res) => {
          this.Address = res.userInfo.address;
          console.log(this.Address);
        });
    },
    sumbit() {
      console.log("修改用户信息");
      let address = this.$refs.nameInput.value;
      this.$taxios.postInfo("/updateUserInfo",{address:address}).then((res) => {
        console.log(res);
        location.reload();
        this.$message.promptBox("修改成功","success")
      });
    },
  },
  created() {
    if (sessionStorage.getItem("token")) {
      this.getUserInfo();
    }
  },
};
</script>
<style  lang="less" scoped>
.basicinfo-container {
  // display: none;
  .box {
    width: 100%;
    padding-left: 20px;
    padding-top: 20px;
    padding-right: 20px;
    // background: pink;
    text-align: left;
    box-sizing: border-box;

    span {
      color: rgba(128, 128, 128, 0.8);
    }

    .info-input {
      padding-top: 10px;
      width: 100%;

      input {
        width: 100%;
        outline: none;
        height: 30px;
        padding-left: 10px;
        border: 1px solid rgba(128, 128, 128, 0.5);
        border-radius: 5px;
      }

      input:focus {
        border: 1px solid #2469e5;
      }

      textarea {
        width: 100%;
        outline: none;
        height: 50px;
        padding-top: 10px;
        padding-left: 10px;
        border: 1px solid rgba(128, 128, 128, 0.5);
        border-radius: 5px;
        font-size: 18px;
        resize: vertical;
      }

      textarea:focus {
        border: 1px solid #2469e5;
      }
    }
  }

  .sumbit-button {
    height: 70px;
    text-align: right;
    padding-right: 20px;
    box-sizing: border-box;

    button {
      position: relative;
      top: 10px;
      width: 100px;
      height: 40px;
      border: none;
      border-radius: 5px;
      background: #2469e560;
      color: #fff;
      cursor: pointer;
      transition: 0.5s;
    }

    button:hover {
      background: #2469e5;
    }
  }
}
</style>